﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineCellphoneStore.UserPages
{
    public partial class CheckOut : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UserContext();
            }
        }
        private void UserContext()
        {
            HandleUserLables();
            if (Session["Currency"] == null)
            {
                Session["Currency"] = "NIS";
            }
            if (Session["AmountToBuy"] == null)
            {
                Session["AmountToBuy"] = Double.Parse(Session["TotalAmount"].ToString());
            }
            if (Session["Calender"] == null)
            {
                Session["Calender"] = DateTime.Now;
            }
        }
        private void HandleUserLables()
        {
            // Update labels
            aHelloUser.InnerHtml += Session["UserName"].ToString();
            aLastEntered.InnerHtml += Session["LastVisit"].ToString();
        }
        protected void LogOut_Click(object sender, EventArgs e)
        {
            string Url = "../Main.aspx?LogOut=true";
            Response.Redirect(Url, false);
        }
        protected void Calendar_SelectionChanged(object sender, EventArgs e)
        {
            Session["Calender"] = ((Calendar)sender).SelectedDate;
        }
        protected void PayBtn_Click(object sender, EventArgs e)
        {
            string Url = "../UserPages/OrderSummary.aspx";
            Response.Redirect(Url, false);
        }
    }
}